%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/polymorphic/allRelationalTopics.condition"
    Bucket0("Bucket 0 (root)<br /><br />1: 70, 74<br />ᐳ: 6, 8, 11, 12, 7, 13, 15, 17, 22<br />2: PgSelect[10], PgSelect[19]<br />ᐳ: Access[71], Access[75]<br />3: Connection[14], Connection[21]<br />4: 24, 27"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 14, 24, 71<br /><br />ROOT Connectionᐸ10ᐳ[14]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 21, 27, 75<br /><br />ROOT Connectionᐸ19ᐳ[21]"):::bucket
    Bucket5("Bucket 5 (listItem)<br />Deps: 71<br /><br />ROOT __Item{5}ᐸ24ᐳ[30]"):::bucket
    Bucket6("Bucket 6 (listItem)<br />Deps: 75<br /><br />ROOT __Item{6}ᐸ27ᐳ[32]"):::bucket
    Bucket7("Bucket 7 (nullableBoundary)<br />Deps: 71, 31<br /><br />ROOT PgSelectSingle{5}ᐸrelational_topicsᐳ[31]<br />1: <br />ᐳ: List[72], Lambda[73]<br />2: PgSelectRows[40]<br />ᐳ: 39, 41, 42, 57, 63, 69"):::bucket
    Bucket8("Bucket 8 (nullableBoundary)<br />Deps: 75, 33<br /><br />ROOT PgSelectSingle{6}ᐸrelational_topicsᐳ[33]<br />1: <br />ᐳ: List[76], Lambda[77]<br />2: PgSelectRows[49]<br />ᐳ: 48, 50, 51"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket1 --> Bucket5
    Bucket2 --> Bucket6
    Bucket5 --> Bucket7
    Bucket6 --> Bucket8

    %% plan dependencies
    PgSelect10[["PgSelect[10∈0] ➊<br />ᐸrelational_topicsᐳ"]]:::plan
    Object13{{"Object[13∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    ApplyInput15{{"ApplyInput[15∈0] ➊"}}:::plan
    PgSelectInlineApply70["PgSelectInlineApply[70∈0] ➊"]:::plan
    Object13 & ApplyInput15 & PgSelectInlineApply70 --> PgSelect10
    PgSelect19[["PgSelect[19∈0] ➊<br />ᐸrelational_topicsᐳ"]]:::plan
    ApplyInput22{{"ApplyInput[22∈0] ➊"}}:::plan
    PgSelectInlineApply74["PgSelectInlineApply[74∈0] ➊"]:::plan
    Object13 & ApplyInput22 & PgSelectInlineApply74 --> PgSelect19
    __InputObject7{{"__InputObject[7∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]<br />- Constantᐸnullᐳ[8]"}}:::plan
    Access11{{"Access[11∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access11 & Access12 --> Object13
    __InputObject17{{"__InputObject[17∈0] ➊<br />More deps:<br />- Constantᐸundefinedᐳ[6]<br />- Constantᐸnullᐳ[8]"}}:::plan
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access11
    __Value2 --> Access12
    Connection14[["Connection[14∈0] ➊<br />ᐸ10ᐳ"]]:::plan
    PgSelect10 --> Connection14
    __InputObject7 --> ApplyInput15
    Connection21[["Connection[21∈0] ➊<br />ᐸ19ᐳ"]]:::plan
    PgSelect19 --> Connection21
    __InputObject17 --> ApplyInput22
    ConnectionItems24[["ConnectionItems[24∈0] ➊"]]:::plan
    Connection14 --> ConnectionItems24
    ConnectionItems27[["ConnectionItems[27∈0] ➊"]]:::plan
    Connection21 --> ConnectionItems27
    Access71{{"Access[71∈0] ➊<br />ᐸ10.m.joinDetailsFor35ᐳ"}}:::plan
    PgSelect10 --> Access71
    Access75{{"Access[75∈0] ➊<br />ᐸ19.m.joinDetailsFor44ᐳ"}}:::plan
    PgSelect19 --> Access75
    __Item30[/"__Item[30∈5]<br />ᐸ24ᐳ"\]:::itemplan
    ConnectionItems24 ==> __Item30
    PgSelectSingle31{{"PgSelectSingle[31∈5]<br />ᐸrelational_topicsᐳ"}}:::plan
    __Item30 --> PgSelectSingle31
    __Item32[/"__Item[32∈6]<br />ᐸ27ᐳ"\]:::itemplan
    ConnectionItems27 ==> __Item32
    PgSelectSingle33{{"PgSelectSingle[33∈6]<br />ᐸrelational_topicsᐳ"}}:::plan
    __Item32 --> PgSelectSingle33
    List72{{"List[72∈7]<br />ᐸ71,31ᐳ"}}:::plan
    Access71 & PgSelectSingle31 --> List72
    First39{{"First[39∈7]"}}:::plan
    PgSelectRows40[["PgSelectRows[40∈7]"]]:::plan
    PgSelectRows40 --> First39
    Lambda73{{"Lambda[73∈7]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda73 --> PgSelectRows40
    PgSelectSingle41{{"PgSelectSingle[41∈7]<br />ᐸrelational_itemsᐳ"}}:::plan
    First39 --> PgSelectSingle41
    PgClassExpression42{{"PgClassExpression[42∈7]<br />ᐸ__relation...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle41 --> PgClassExpression42
    PgClassExpression57{{"PgClassExpression[57∈7]<br />ᐸ__relation...s__.”type”ᐳ"}}:::plan
    PgClassExpression42 o--o PgClassExpression57
    PgClassExpression63{{"PgClassExpression[63∈7]<br />ᐸ__relation...reated_at”ᐳ"}}:::plan
    PgClassExpression57 o--o PgClassExpression63
    PgClassExpression69{{"PgClassExpression[69∈7]<br />ᐸ__relation...chived_at”ᐳ"}}:::plan
    PgClassExpression63 o--o PgClassExpression69
    List72 --> Lambda73
    List76{{"List[76∈8]<br />ᐸ75,33ᐳ"}}:::plan
    Access75 & PgSelectSingle33 --> List76
    First48{{"First[48∈8]"}}:::plan
    PgSelectRows49[["PgSelectRows[49∈8]"]]:::plan
    PgSelectRows49 --> First48
    Lambda77{{"Lambda[77∈8]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda77 --> PgSelectRows49
    PgSelectSingle50{{"PgSelectSingle[50∈8]<br />ᐸrelational_itemsᐳ"}}:::plan
    First48 --> PgSelectSingle50
    PgClassExpression51{{"PgClassExpression[51∈8]<br />ᐸ__relation...ems__.”id”ᐳ"}}:::plan
    PgSelectSingle50 --> PgClassExpression51
    List76 --> Lambda77

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,__InputObject7,PgSelect10,Access11,Access12,Object13,Connection14,ApplyInput15,__InputObject17,PgSelect19,Connection21,ApplyInput22,ConnectionItems24,ConnectionItems27,PgSelectInlineApply70,Access71,PgSelectInlineApply74,Access75 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2 bucket2
    classDef bucket5 stroke:#7fff00
    class Bucket5,__Item30,PgSelectSingle31 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,__Item32,PgSelectSingle33 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,First39,PgSelectRows40,PgSelectSingle41,PgClassExpression42,PgClassExpression57,PgClassExpression63,PgClassExpression69,List72,Lambda73 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,First48,PgSelectRows49,PgSelectSingle50,PgClassExpression51,List76,Lambda77 bucket8

